/**
 * 
 */
package qy.qyalgotrader.mystrategy;

import java.util.Map;

import qy.jalgotrade.dataseries.SequenceDataSeries;

/**
 * @author c-geo
 *
 */
public final class StratUtils {

	public static class RiskMan {

		/**
		 * 
		 * @param params
		 * @return
		 */
		public static RiskMan create(Map<String, Object> params) {

			double hardStopLossRatio = (double) params.getOrDefault("hardSl", 0.005);
			double cashUtilizaton = (double) params.getOrDefault("cashUtil", 0.55);
			double volatilityEstimated = (double) params.getOrDefault("volaEstim", 0.03);

			return new RiskMan(hardStopLossRatio, cashUtilizaton, volatilityEstimated);
		}

		/**
		 * 硬止损 (缺省: 0.5%):
		 */
		private double __hardStopLossRatio;

		/**
		 * 资金使用率 (缺省: 55%):
		 */
		private double __cashUtilizaton;

		/**
		 * 波动率预估 (缺省: 3%):
		 */
		private double __volatilityEstimated;

		/**
		 * 
		 */
		public RiskMan() {

			this(0.005, 0.55, 0.03);
		}

		/**
		 * 
		 * @param hardSl 硬止损 (缺省: 0.5%)
		 */
		public RiskMan(double hardSl) {

			this(hardSl, 0.55, 0.03);
		}

		/**
		 * 
		 * @param hardSl   硬止损 (缺省: 0.5%)
		 * @param cashUtil 资金使用率 (缺省: 55%)
		 */
		public RiskMan(double hardSl, double cashUtil) {

			this(hardSl, cashUtil, 0.03);
		}

		/**
		 * 
		 * @param hardSl    硬止损 (缺省: 0.5%)
		 * @param cashUtil  资金使用率 (缺省: 55%)
		 * @param volaEstim 波动率预估 (缺省: 3%)
		 */
		public RiskMan(double hardSl, double cashUtil, double volaEstim) {

			__hardStopLossRatio = hardSl;
			__cashUtilizaton = cashUtil;
			__volatilityEstimated = volaEstim;
		}

		public double getHardStopLossRatio() {

			return __hardStopLossRatio;
		}

		public double getCashUtilizaton() {

			return __cashUtilizaton;
		}

		public double getVolatilityEstimated() {

			return __volatilityEstimated;
		}
	}

	public enum MySignalMode {

		DEFAULT, // 多 / 空
		LONG_ONLY, // 仅做多
		SHORT_ONLY; // 仅做空
	}

	public enum MultiFrequencyMeasure {

		MICRO, // micro
		SHORT, // short
		MEDIUM, // medium
		LONG, // long
		TREND_RECOG, // trendRecog
		POS_HOLDING // posHolding
	}

	public static SequenceDataSeries<Double> CONST_DS_0;

	public static SequenceDataSeries<Double> CONST_DS_50;

	public static SequenceDataSeries<Double> CONST_DS_10;

	public static SequenceDataSeries<Double> CONST_DS_20;

	public static SequenceDataSeries<Double> CONST_DS_80;

	public static SequenceDataSeries<Double> CONST_DS_90;

	static {

		try {
			CONST_DS_0 = SequenceDataSeries.makeConstSequenceDataseries(0.0, 2, Double.class, 2);
			CONST_DS_50 = SequenceDataSeries.makeConstSequenceDataseries(50.0, 2, Double.class, 2);
			CONST_DS_10 = SequenceDataSeries.makeConstSequenceDataseries(10.0, 2, Double.class, 2);
			CONST_DS_20 = SequenceDataSeries.makeConstSequenceDataseries(20.0, 2, Double.class, 2);
			CONST_DS_80 = SequenceDataSeries.makeConstSequenceDataseries(80.0, 2, Double.class, 2);
			CONST_DS_90 = SequenceDataSeries.makeConstSequenceDataseries(90.0, 2, Double.class, 2);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * 
	 */
	private StratUtils() {

	}
}
